<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!doctype html>
<html lang="en">
<head>
<jsp:include page="commons.jsp"></jsp:include>
<script type="text/javascript" src="highcharts/highcharts.js"></script>
<script type="text/javascript" src="highcharts/exporting.js"></script>
<script>
	$(function() {
		$(document).ready(
				function() {
					Highcharts.setOptions({
						global : {
							useUTC : false
						}
					});
					var chart;
					$('#container').highcharts(
							{
								chart : {
									type : 'line',
									animation : Highcharts.svg, // don't animate in old IE               
									marginRight : 10,
									events : {
										load : function() {
											// set up the updating of the chart each second             
											var series = this.series[0];
											setInterval(function() {
												var x = (new Date()).getTime(), // current time         
												y = 36.5+Math.random()*5;
												series.addPoint([ x, y ], true,
														true);
											}, 1000);
										}
									}
								},
								title : {
									text : '实时体温数据图'
								},
								xAxis : {
									type : 'datetime',
									tickPixelInterval : 150
								},
								yAxis : {
									title : {
										text : '体温数据'
									},
									plotLines : [ {
										value : 0,
										width : 1,
										color : '#808080'
									} ]
								},
								tooltip : {
									formatter : function() {
										return '<b>'
												+ this.series.name
												+ '</b><br/>'
												+ Highcharts.dateFormat(
														'%Y-%m-%d %H:%M:%S',
														this.x)
												+ '<br/>'
												+ Highcharts.numberFormat(
														this.y, 2);
									}
								},
								legend : {
									enabled : false
								},
								exporting : {
									enabled : true
								},
								series : [ {
									name : '体温数据',
									data : (function() {
										// generate an array of random data                             
										var data = [], time = (new Date())
												.getTime(), i;
										var number;
										var value;
										for (i = -19; i <= 0; i++) {
											number=36.5+Math.random()*5;
											data.push({
												x : time + i * 5000,
												y : number
											});
										}
										return data;
									})()
								} ]
							});
				});

	});
	function queryData(){
		var params={};
		var timeInfo=$("#query_startTime").val();
		if(timeInfo){
			params['startTime']=timeInfo;
		}
		timeInfo=$("#query_endTime").val();
		if(timeInfo){
			params['startTime']=timeInfo;
		}
		$.post('gather/query.action',params,function(result){
	        if (result.success){
	        	alert('query result:');
	        	//$('#dg').datagrid('reload'); // reload the user data
	        } else {
	        	$.messager.show({ // show error message
	        		title: '错误',
	        		msg: result.errorMsg
	        	});
	        }
	    },'json');
	}
	function printData(){
		window.open('show/print.action');
	}
	function exportData(){
		window.open('show/export.action');
	}
</script>
</head>
<body>
	<div id="toolbar">
		<span style="font-size: 12px">开始时间:</span><input class="f1 easyui-datetimebox" name="startTime" id="query_startTime"/>&nbsp;&nbsp;-&nbsp;&nbsp;<span style="font-size: 12px">结束时间:</span><input class="f1 easyui-datetimebox" name="endTime" id="query_endTime"/>
		<a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-search" onclick="queryData()">查询</a>
		<a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-print" onclick="printData()">打印</a>
		<a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-print" onclick="exportData()">导出</a>
	</div>
	<div id="container"></div>
</body>
</html>